<?php
abstract class Model {
	private $db;
	
	protected function query($sql, $args_to_prepare = null, $exception_on_missing_args = false) {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->query($sql,$args_to_prepare,$exception_on_missing_args);
	}

	protected function numRows($arg = null) {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->numRows($arg);
	}

	protected function hasRows($arg = null) {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->hasRows($arg);
	}

	protected function affectedRows() {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->affectedRow();
	}

	protected function insertId() {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->insertId();
	}

	protected function getValue($arg = null) {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->getValue($arg);
	}

	protected function getValues($arg = null) {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->getValues($arg);
	}

	protected function getRow($arg = null) {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->getRow($arg);
	}

	protected function getRows($arg = null) {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->getRows($arg);
	}

	protected function quote($var) {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->quote($var);
	}
	
	protected function escape($var) {
		if ($this->db == null) $this->db = Database::getDatabase();
		return $this->db->escape($var);
	}
}
